/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.PeriodPaymentLaundryDao;
import com.click.app.model.PeriodPaymentLaundry;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ronald
 */
public class PeriodPaymentLaundryDaoHibernate  extends GenericDaoHibernate<PeriodPaymentLaundry, Long>
                                        implements PeriodPaymentLaundryDao {

    public PeriodPaymentLaundryDaoHibernate() {
        super(PeriodPaymentLaundry.class);
    }

    public PeriodPaymentLaundry findCurrentPeriodByLaundry(Long id){
        List<PeriodPaymentLaundry> pplList = getHibernateTemplate().find("from PeriodPaymentLaundry where laundry.id=? and closed = false ", id);
        if (pplList == null || pplList.isEmpty()) {
            pplList = new ArrayList();
        }
        return (PeriodPaymentLaundry) pplList.get(0);
    }

}
